﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Quartz;

namespace QuartzExt.JobTypes
{
    /// <summary>
    /// 执行sql server 任务
    /// </summary>
    public class SqlServerJob : BaseJob
    {
       
        public override void Run(IJobExecutionContext context)
        {
            var param = JsonConvert.DeserializeObject<SqlServerJobParam>(context.JobDetail.JobDataMap["AttachParam"].ToString());            
            using (var cnn = new SqlConnection(param.ConnectionString))
            {
                var cmd = cnn.CreateCommand();
                cnn.Open();
                cmd.CommandText = param.CommandText;
                cmd.CommandType = param.CommandType;
                cmd.ExecuteNonQuery();
            }
        }
    }
}
